package com.sxfq.loansupermarket.backsystem.modular.marketing.service.impl;

import com.sxfq.loansupermarket.backsystem.modular.arrival.service.ICustomerService;
import com.sxfq.loansupermarket.backsystem.modular.base.SqlMapper;
import com.sxfq.loansupermarket.backsystem.modular.marketing.entity.ReservationsInfo;
import com.sxfq.loansupermarket.backsystem.modular.marketing.service.IReservationsTabService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
@Transactional
public class ReservationsTabServiceImpl implements IReservationsTabService {
    @Autowired
    private SqlMapper sqlMapper;

    @Autowired
    ICustomerService customerService;

    //市场患者点人名，tab患者信息查询
    public ReservationsInfo getReservationsInformation(String id) {
        String sql = "select " +
                "  (CASE a.customer_sex  " +
                "  WHEN 1 THEN  " +
                "  '男'  " +
                "  WHEN 2 THEN  " +
                "  '女'  " +
                "  ELSE  " +
                "  '未知'  " +
                "  END  " +
                " ) as sex ,left(a.appointment_time,19) as appointmentTime," +
                "left(a.filing_time,19) as filingTime,a.* from reservations_info a where id= '" + id + "' limit 0,1";
        ReservationsInfo reservationsInfo = sqlMapper.selectOne(sql, ReservationsInfo.class);
        return  reservationsInfo;
    }

    //市场患者点人名，tab回访信息查询
    public ReservationsInfo getReservationsHuifang(String id) {
        String sql = "select left(a.appointment_time,19) as appointmentTime,left(a.lasthuifangtime,19) as lasthuifangtime " +
                ",department as department ,follower as follower from reservations_info a where id= '" + id + "' limit 0,1";
        ReservationsInfo reservationsInfo = sqlMapper.selectOne(sql, ReservationsInfo.class);
        return  reservationsInfo;
    }
}